function setDate(id) {
    var Nowdate=new Date();
    M=Number(Nowdate.getMonth())+1;
    var today=Nowdate.getFullYear()+"-"+fix(M)+"-"+fix(Nowdate.getDate());

     //明天的时间
     var day3 = new Date();
     day3.setTime(day3.getTime()+24*60*60*1000);
     var tommorrow = day3.getFullYear()+"-" + fix(M) + "-" + day3.getDate();
    if(id=='1'){
        $("#startDate").val(today);
        $("#endDate").val(tommorrow);
    }else if(id=='2'){
        $("#startDate").val(showWeekFirstDay());
        $("#endDate").val(tommorrow);
    }if(id=='3'){
        $("#startDate").val(showMonthFirstDay());
        $("#endDate").val(tommorrow);
    }
    query()

}

$(function(){
	$(".btn-container .normal-btn").each(function(index,ele){
		$(this).bind('click',function(){
			$(this).css({'background-color':'#38ea30'})
			$(this).siblings().css({'background-color':'#2c99f7'})
			event.stopPropagation()
		})
	})
	$(":not(.normal-btn)").click(function(){
		$(".btn-container .normal-btn").css({'background-color':'#2c99f7'})
	})
})

function showWeekFirstDay()
{
    var Nowdate=new Date();
    var WeekFirstDay=new Date(Nowdate-(Nowdate.getDay()-1)*86400000);
    M=Number(WeekFirstDay.getMonth())+1
    return WeekFirstDay.getFullYear()+"-"+fix(M)+"-"+fix(WeekFirstDay.getDate());
}
function showWeekLastDay()
{
    var Nowdate=new Date();
    var WeekFirstDay=new Date(Nowdate-(Nowdate.getDay()-1)*86400000);
    var WeekLastDay=new Date((WeekFirstDay/1000+6*86400)*1000);
    M=Number(WeekLastDay.getMonth())+1
    return WeekLastDay.getFullYear()+"-"+M+"-"+WeekLastDay.getDate();
}
function showMonthFirstDay()
{
    var Nowdate=new Date();
    var MonthFirstDay=new Date(Nowdate.getFullYear(),Nowdate.getMonth(),1);
    M=Number(MonthFirstDay.getMonth())+1
    return MonthFirstDay.getFullYear()+"-"+fix(M)+"-"+fix(MonthFirstDay.getDate());
}
function fix(num){
    if(num<10)
        return "0"+num;
    else return ""+num;
}
function showMonthLastDay()
{
    var Nowdate=new Date();
    var MonthNextFirstDay=new Date(Nowdate.getFullYear(),Nowdate.getMonth()+1,1);
    var MonthLastDay=new Date(MonthNextFirstDay-86400000);
    M=Number(MonthLastDay.getMonth())+1
    return MonthLastDay.getFullYear()+"-"+M+"-"+MonthLastDay.getDate();
}